Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pine: Compute the squared norm just once #649

Merged
merged 1 commit into from
Aug 22, 2024

Conversation

cjpatton
Copy link
Contributor

@cjpatton cjpatton commented Aug 13, 2024

Based on #648 (merge that first).
Partially addresses #618.

Split the existing FLP circuit into two:

  1. One that computes the squared norm bound and checks that it is equal to the claimed value

  2. Another for everything else, including checking that the claimed norm bound is in range and that the wraparound tests succeeded

The first circuit does not require joint randomness to compute, which means we can safely run it once without opening ourselves to offline attacks. It is also the most expensive part of the computation.

This change aligns our implementation with a planned change for the next version of PINE:
junyechen1996/draft-chen-cfrg-vdaf-pine#92
junyechen1996/draft-chen-cfrg-vdaf-pine#94

@cjpatton cjpatton force-pushed the cjpatton/618/8-one-norm-equality-check branch 2 times, most recently from fafa62f to 7f62e60 Compare August 13, 2024 20:56
@cjpatton cjpatton marked this pull request as ready for review August 13, 2024 21:05
Base automatically changed from cjpatton/make-benches-compile to main August 14, 2024 14:19
@cjpatton cjpatton force-pushed the cjpatton/618/8-one-norm-equality-check branch from 7f62e60 to 08aca1a Compare August 14, 2024 14:20
@cjpatton cjpatton requested a review from mendess August 14, 2024 14:24
Split the existing FLP circuit into two:

1. One that computes the squared norm bound and checks that it is equal
   to the claimed value

2. Another for everything else, including checking that the claimed norm
   bound is in range and that the wraparound tests succeeded

The first circuit does not require joint randomness to compute, which
means we can safely run it once without opening ourselves to offline
attacks. It is also the most expensive part of the computation.

This change aligns our implementation with a planned change for the next
version of PINE:

junyechen1996/draft-chen-cfrg-vdaf-pine#92
junyechen1996/draft-chen-cfrg-vdaf-pine#94
@cjpatton cjpatton force-pushed the cjpatton/618/8-one-norm-equality-check branch from 08aca1a to 493b6de Compare August 14, 2024 21:36
@cjpatton cjpatton mentioned this pull request Aug 15, 2024
Copy link
Collaborator

@mendess mendess left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to approve to unblock, but maybe prio should change to have more smaller traits to avoid situations like this? I'm not super familiar with prio but methods like

    fn encode_measurement(&self, _measurement: &()) -> Result<Vec<F>, FlpError>
    fn decode_result(&self, _data: &[F], _num_measurements: usize) -> Result<(), FlpError> 
    fn truncate(&self, _input: Vec<F>) -> Result<Vec<F>, FlpError>
    fn output_len(&self) -> usize

seem to be concerned with the domain of serialization(?) whereas the other methods of the trait seem concerned cryptography itself. Maybe these could be split into two traits?

@cjpatton
Copy link
Contributor Author

I'm going to approve to unblock, but maybe prio should change to have more smaller traits to avoid situations like this? I'm not super familiar with prio but methods like

    fn encode_measurement(&self, _measurement: &()) -> Result<Vec<F>, FlpError>
    fn decode_result(&self, _data: &[F], _num_measurements: usize) -> Result<(), FlpError> 
    fn truncate(&self, _input: Vec<F>) -> Result<Vec<F>, FlpError>
    fn output_len(&self) -> usize

seem to be concerned with the domain of serialization(?) whereas the other methods of the trait seem concerned cryptography itself. Maybe these could be split into two traits?

I agree, see #649 (comment).

Before merging this I want @armfazh to review :)

.chunks(self.cfg.chunk_len_sq_norm_equal)
.map(|chunk| {
for x in chunk {
buf.push(*x);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double-check: push twice?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, this is correct! buf is a sequence of inputs to the Mul gadget, which has two input wires and outputs the multiplication of the inputs. Here we're just using the Mul gadget to square each of the gradient entries.

if !self.flp.decide(verifier)? {
return Err(VdafError::Uncategorized("proof check failed".into()));
return Err(VdafError::Uncategorized("main proof check failed".into()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it maybe good to refactor the 'main' proof and give it a more specific name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately the functional split between the two FLPs is a little awkward. The "main" circuit is everything but the squared norm equality check. In the future we might try to go for a split for which the two circuits would have more meaningful names: junyechen1996/draft-chen-cfrg-vdaf-pine#95

@cjpatton cjpatton merged commit 9b4818b into main Aug 22, 2024
3 checks passed
@cjpatton cjpatton deleted the cjpatton/618/8-one-norm-equality-check branch August 22, 2024 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants